# 每个月的销售额
sales = [1200, 1500, 1800, 1600, 2100]
months = ["Jan", "Feb", "Mar", "Apr", "May"]
# # 1. 计算每月环比增长率
# growth_rates = [(b - a) / a * 100 for a, b in zip(sales, sales[1:])]
# print("每月环比增长率（%）:", growth_rates)
# # 2. 找出增长最快的月份
# max_growth_index = growth_rates.index(max(growth_rates))
# print(
#     "增长最快的月份:",
#     months[max_growth_index + 1],
#     "增长率:",
#     growth_rates[max_growth_index],
#     "%",
# )
# # 3. 判断销售是否持续增长
# is_continuous_growth = all(earlier < later for earlier, later in zip(sales, sales[1:]))
# print("销售是否持续增长:", is_continuous_growth)
# # 4. 将上述信息打印出来
# print(f"销售额: {sales}")
# print(f"月份: {months}")
# print(f"每月环比增长率（%）: {growth_rates}")
# print(
#     f"增长最快的月份: {months[max_growth_index + 1]}，增长率: {growth_rates[max_growth_index]}%"
# )
# print(f"销售是否持续增长: {is_continuous_growth}")


growth_rates = list((b - a) / a * 100 for a, b in zip(sales, sales[1:]))
# g_r = map(lambda a: (a[1] - a[0])  / a[0] * 100, list(zip(sales, sales[1:])))
# print(list(g_r))
# for i in range(len(growth_rates)):
#     print(growth_rates[i])

#     growth_rates[i] = (
#         (growth_rates[i][1] - growth_rates[i][0]) / growth_rates[i][0] * 100
#     )
print("每月环比增长率（%）:", growth_rates)

max_growth_index = growth_rates.index(max(growth_rates))
print(
    "增长最快的月份:",
    months[max_growth_index + 1],
    "增长率:",
    growth_rates[max_growth_index],
)
print("销售是否持续增长:", all(growth_rate > 0 for growth_rate in growth_rates))
